1. Field of the Invention
Methods and apparatuses consistent with the present invention relate to storing data in nonvolatile memory, and more particularly, to managing blocks according to the update type of data in block-type memory.
2. Description of the Related Art
In the related art, flash memory is impact resistant and has a low power consumption, and has been used as storage in mobile devices and embedded systems.
Generally, NAND flash memory is divided into a page consisting of a 512-byte (1 sector) or 2048-byte (4 sectors) data area and a 16-byte or 64-byte backup area, and a block that has bound several pages as one bundle. One NAND flash memory consists of multiple blocks. To carry out a write operation on an already-written page, the NAND flash memory must perform an erase operation that erases the whole block to which the sector belongs. Further, the number of times each block can be erased is related to the lifetime of the NAND flash memory, and thus all blocks of the NAND flash memory should be evenly used.
To provide linear space, in which reading and writing is possible in sector units, such as in a hard disk, flash memory needs a separate Flash Translation Layer (FTL) because of the different physical structure. The FTL converts a requested logical address into a physical address on flash memory in upper application.
In a related art FTL that uses a mapping method, logically-consecutive sectors can be recorded in different physical positions. Because an erasing unit is bigger than a writing unit in the NAND flashy memory, when reaching a certain limit, the work of collecting consecutive data dispersed in different physical positions into the same address space using random blocks is called merging.
FIG. 1 illustrates a merging operation of a flash memory. As shown in blocks LSN #512-#767, data, which physically needs to exist within the same block has been physically dispersed in two or more blocks. The dispersed data is copied to the same physical block 10 (a merging operation).
Further, a file system is an application operated in the upper layer of the FTL; it records predetermined data about a certain logical address in the FTL or reads recorded data. Because such a file system has been designed for magnetic disks such as a hard disk or a floppy disk, characteristics of the aforementioned related art flash memory are not reflected well. For example, correction of data recorded on a magnetic disk can be achieved only by writing new data to the position where the existing data was recorded. However, in the case of NAND flash memory, the work of invalidating conversion information on the page, on which the existing data has been recorded, writing new data to the new page, then correcting the conversion information should be performed due to the physical characteristics of the memory. Hence, frequent data-correction requests sent to the FTL will cause frequent merging operations.
FIG. 2 illustrates block space of related art flash memory. A file system in the memory space (shown by reference numeral 15) is produced by formatting. Address space on a disk is divided into space where metadata to manage data of a file system is recorded, and block space. As shown by reference numeral 20, block space is divided into data blocks that include one or more sectors, and as shown by reference numeral 25, and blocks data are managed by the file system.
The file system calculates the size of file-system metadata, which is necessary for managing the whole storage space in the formatting process as shown by reference numeral 15, then allocates space for the file-system metadata, and allocates remaining space as block space.
The file system allocates usable data blocks so as to add a new file or record content of a file. A newly-allocated data block is indicated as a data block “in use” by the file system.
As described above, the file system allocates the entire storage space by storing file-system metadata and data to be recorded by the upper application.
However, such data is often differs in the access pattern. For example, the file-system metadata is small compared with regular data, and is often edited. Further, regular data is relatively large, but after being recorded the data is not often edited compared with the file-system metadata.
Hence, frequently-corrected data and rarely-corrected data are scattered in the storage space. If different types of data exist in the same block of the NAND flash, the block can frequently be the object of merging. Such frequent merging may lower the total performance of the file system, and may reduce the lifetime of flash memory.
Therefore, there is a need for a method and apparatus for effectively using flash memory considering data access or characteristics of recording.